package com.wuyan.locationdog.ui.device


import androidx.activity.viewModels
import com.arcsoft.commonbase.R
import com.arcsoft.commonbase.base.BaseBindingActivity
import com.arcsoft.commonbase.bean.DeviceBeanContent
import com.arcsoft.commonbase.ext.ImageOptions
import com.arcsoft.commonbase.ext.defaultText
import com.arcsoft.commonbase.ext.loadImage
import com.arcsoft.commonbase.ext.loadImageCircleCar
import com.arcsoft.commonbase.ext.radius
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.BarUtils
import com.wuyan.locationdog.databinding.DogFilesDetailActivityBinding
import com.wuyan.locationdog.databinding.FlowDetailActivityBinding
import com.wuyan.locationdog.help.DogHelp
import com.wuyan.locationdog.viewmodel.DeviceViewModel

class DogFilesDetailActivity : BaseBindingActivity<DogFilesDetailActivityBinding>() {
    private val mViewModel: DeviceViewModel by viewModels()

    override fun initData() {


        BarUtils.transparentStatusBar(this)
        setTitleText("")
        binding.apply {

            btnModify.setOnClickListener {
                DogHelp.isModifyDogFile = true
                ActivityUtils.startActivity(DogAddFilesActivity::class.java)
            }
        }


    }

    override fun onResume() {
        super.onResume()
        val map = HashMap<String, Any>()
        map["dogId"] = DogHelp.mDogFileBeanContent?.dogId.toString()
        mViewModel.getDogDetail(map)

    }

    override fun observe() {
        super.observe()
        mViewModel.mDogFileBeanContent.observe(this) {
            it.content?.let {
                DogHelp.mDogFileBeanContent = it
                binding.apply {

                    dogImg.loadImage(it.dogImg, ImageOptions().apply {
                        placeholder = com.wuyan.locationdog.R.mipmap.dog_file_def
                        error = com.wuyan.locationdog.R.mipmap.dog_file_def
                        fallback = com.wuyan.locationdog.R.mipmap.dog_file_def
                    })

                    dogName.text = it.dogName
                    dogType.text = it.dogType
                    age.text = it.age
                    if (!it.weight.isNullOrEmpty()) {
                        weight.text = it.weight + "kg"
                    }
                    remark.text = it.remark
                    gender.text = it.gender
                }
            }
        }
    }
}